﻿#region Includes
using System;
using System.Runtime.InteropServices;
#endregion

namespace GingerGL.Graphics.Models.MD3
{
    //------------------------------------------------------------//
    /// <summary>
    /// IDS MD3 Surface Header
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
    public struct MD3SurfaceHeader
    {
        //--------------------------------------------------------//
        #region Variables
        public UInt32 Ident;                                    // Magic number. As a string of 4 octets, reads "IDP3"; as unsigned little-endian 860898377 (0x33504449);
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
        public char[] Name;                                     //Name of Tag object. ASCII character string, NUL-terminated (C-style)
        public UInt32 Flags;                                    // ???

        public Int32 FrameCount;                                // Number of animation frames. This should match NUM_FRAMES in the MD3 header.
        public Int32 ShaderCount;                               // Number of Shader objects defined in this Surface, with a limit of MD3_MAX_SHADERS. Current value of MD3_MAX_SHADERS is 256.
        public Int32 VertCount;                                 // Number of Vertex objects defined in this Surface, up to MD3_MAX_VERTS. Current value of MD3_MAX_VERTS is 4096.
        public Int32 TriangleCount;                             // Number of Triangle objects defined in this Surface, maximum of MD3_MAX_TRIANGLES. Current value of MD3_MAX_TRIANGLES is 8192.

        public Int32 TriangleOffset;                            // Relative offset from SURFACE_START where the list of Triangle objects starts.
        public Int32 ShaderOffset;                              // Relative offset from SURFACE_START where the list of Shader objects starts.
        public Int32 UVOffset;                                  // Relative offset from SURFACE_START where the list of ST objects (s-t texture coordinates) starts.
        public Int32 VertOffset;                                // Relative offset from SURFACE_START where the list of Vertex objects (X-Y-Z-N vertices) starts.
        public Int32 EndOffset;                                 // Relative offset from SURFACE_START to where the Surface object ends.
        #endregion
        //--------------------------------------------------------//
    }
    //------------------------------------------------------------//
}
